/**
 * 
 */

package cn.iune.erp.sale;

import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;

import com.justep.baas.data.RowState;

/**
 * @author Administrator
 *
 */
@Entity
@Table(name = "SaleOrderDetail"
, uniqueConstraints = { 
	@UniqueConstraint(columnNames = { "orderNo", "serialNo", "enterpriseNo" }) 
}
)
@NamedQuery(name="SaleOrderDetail.findAll", query="SELECT s FROM SaleOrderDetail s")
public class SaleOrderDetail {

	@Id
	@Column(length=36)
	private String fID;
	
	@Column(length=4)
	private String orderType;
	@Column(length=10)
	private String orderTypeLabel;
	
	@Column(length=32)
	private String systemCode;
	@Column(length=4)
	private String billType;
	@Column(length=20)
	private String billTypeName;
	private Date orderDate;
	@Column(length=10)
	private String state = "active";
	@Column(length=10)
	private String status = "open";
	@Column(length=10)
	private String audit = "active";

	private Date confirmDate;
	
	@Column(length=4)
	private String origin;
	@Column(length=20)
	private String originName;
	@Column(length=20)
	private String originNo;
	@Column(length=5)
	private String originSerialNo;
	
	@Column(length=15)
	private String orderNo;
	
	@Column(length=32)
	private String factoryID;
	@Column(length=15)
	private String factoryNo;
	@Column(length=20)
	private String factoryName;
	
	@Column(length=3)
	private String storageTypeD;
	@Column(length=20)
	private String storageTypeDLabel;
	@Column(length=32)
	private String customerID;
	@Column(length=15)
	private String customerNo;
	@Column(length=20)
	private String shortName;
	@Column(length=128)
	private String customerName;
	
	@Column(length=3)
	private String storageType;
	@Column(length=20)
	private String storageTypeLabel;
	@Column(length=32)
	private String storageID;
	@Column(length=15)
	private String storageNo;
	@Column(length=20)
	private String storageName;
	@Column(length=128)
	private String floorNo;
	@Column(length=5)
	private String allowed;//库存量不足准许出库：yes，否则：no
	
	private int taxType = 0;
	@Column(length=10)
	private String taxTypeLabel;
	@Column(precision=10,scale=2)
	private BigDecimal taxRate = BigDecimal.ZERO;

	@Column(length=5)
	private String serialNo;
	@Column(length=32)
	private String fMasterID;
	
	@Column(length=32,nullable=true)
	private String sbomID;//销售BOM（成套出售时使用）
	private int lv = 0;//主件：0，元件：1
	private int sttts = 1;//是否参加数量和金额的统计。不参加：0，参加：1
	
	private int checkin = 1;//是否参加出入库登记（影响单据总数量）。不参加（不计入单据总数量）：0，参加：1
	
	//预占库存
	int frozenFlag = 0;
	
	@Column(length=32)
	private String itemID;
	@Column(length=30)
	private String itemNo;
	@Column(length=100)
	private String itemName;
	@Column(length=512)
	private String itemProperty;// = "*****";
	@Transient
	private String itemDescribe;
	@Column(length=15)
	private String unitCode;
	@Column(length=20)
	private String unitName;

	/////////////////////////////////////////////////////////////////
	@Transient
	private int qualityType = 0;
	@Transient
	@Column(length=10)
	private String qualityTypeLabel = "0:免检";//0:免检,1:抽检,2:全检
	@Transient
	@Column(length=20)
	private String batchNo;
	@Transient
	private int qualityPeriod = 0;//0,不启用保质期管理；1，启用
	@Transient
	private int validDays = 0;//有效天数
	@Transient
	private int checkoutAgainDays = 0;//复检天数
	
	@Transient
	@Column(length=1024)
	private String storeNo;

	@Transient
	@Column(length=1)
	private String process;
	@Transient
	@Column(length=10)
	private String processLabel;

	@Transient
	@Column(length=30)
	private String barcode;
	///////////////////////////////////////////////////////////////////////////
	
	@Transient
	@Column(length=256)
	private String pic;
	
	@Column(precision=38,scale=6)
	private BigDecimal itemPrice = BigDecimal.ZERO;
	@Column(precision=10,scale=2)
	private BigDecimal discountRate = BigDecimal.ZERO;
	
	//整单折扣（额），与上面的折扣率没有关系
	@Column(precision=38,scale=2,columnDefinition="DECIMAL(38,2) default 0")
	private BigDecimal discountAmount = BigDecimal.ZERO;//整单折扣//扣款金额
	//折后价（交易价格：包含单价折扣率和整单折扣额扣除后的单价）
//	@Column(precision=38,scale=6)
//	private BigDecimal discountPrice = BigDecimal.ZERO;

	@Column(precision=10,scale=2)
	private BigDecimal itemAmount = BigDecimal.ZERO;
	@Column(precision=38,scale=2)
	private BigDecimal orderAmount = BigDecimal.ZERO;
	@Column(precision=38,scale=2)
	private BigDecimal orderAmountOld = BigDecimal.ZERO;
	@Column(precision=38,scale=2)
	private BigDecimal orderAmountTax = BigDecimal.ZERO;
	@Column(precision=38,scale=2)
	private BigDecimal orderAmountTotal = BigDecimal.ZERO;

	//件装（每包装数量，如：每箱啤酒24瓶piecePackage=24，itemAmount=48，则pieceQuantity=2件）
	@Column(precision=10,scale=2,columnDefinition="DECIMAL(10,2) default 0")
	private BigDecimal piecePackage = BigDecimal.ZERO;
	//件数
	@Column(precision=10,scale=2)
	private BigDecimal pieceQuantity = BigDecimal.ZERO;
	
	private Date requirementDate;

	//正在出库数量
	@Column(precision=10,scale=2)
	private BigDecimal pickItemIng = BigDecimal.ZERO;
	//已经完成出库数量（当产生退库时，此数量需要被剪掉）
	@Column(precision=10,scale=2)
	private BigDecimal pickItemAmount = BigDecimal.ZERO;
	@Column(precision=10,scale=2)
    private BigDecimal pickPiece = BigDecimal.ZERO;  

//	@Column(precision=10,scale=2)
//	private BigDecimal backItemIng = BigDecimal.ZERO;
	//累计退库数量
	@Column(precision=10,scale=2)
	private BigDecimal backItemAmount = BigDecimal.ZERO;
	@Column(precision=10,scale=2)
	private BigDecimal backPiece = BigDecimal.ZERO;  
	
	//可出库数量=itemAmount-pickItemIng-pickItemAmount(与累计退库数量backItemAmount无关)
	@Transient
	@Column(precision=10,scale=2)
	private BigDecimal pendingQuantity = BigDecimal.ZERO;//可出库数量
	@Transient
	@Column(precision=10,scale=2)
	private BigDecimal pendingPiece = BigDecimal.ZERO;//可出库件数

	//配货数量
	@Column(precision=10,scale=2,columnDefinition="DECIMAL(10,2) default 0",nullable=false)
	private BigDecimal storeItemAmount = BigDecimal.ZERO;

	@Column(precision=10,scale=2)
	private BigDecimal itemWeight = BigDecimal.ZERO;
	@Column(length=20)
	private String itemSize;

	@Column(precision=10,scale=2)
	private BigDecimal orderWeight = BigDecimal.ZERO;
	@Column(length=20)
	private String orderSize;
	
	@Column(length=20)
	private String projectNo;

	////////////////////////////////////////////////////////////
	//门店流水号（客人流水号）
	@Transient
	@Column(length=20)
	private String guestNumber;
	@Transient
	@Column(length=32)
	private String ssID;
	@Transient
	private int handling = -2;
	@Transient
	@Column(length=10)
	private String handlingLabel = "待提交";//网上订单处理
	@Transient
	@Column(columnDefinition="INT default 0",nullable=false)
	private int packFlag = 0;//是否打包（0：不打包，1：打包）
	////////////////////////////////////////////////////////////

	//作废
//	@Column(precision=38,scale=2)
//	private BigDecimal freightAmount = BigDecimal.ZERO;//运费
	
	@Column(length=20)
	private String resultStatus = "待审核";
	
//	private int passed = 0;//已经传递到下一个环节：1，否则：0。如：订单已经下达到后厨。
	
	@Column(length=4)
	private String next;
	@Column(length=20)
	private String nextName;
	@Column(length=20)
	private String nextNo;

//	@Column(length=32)
//	private String departmentNo;
//	@Column(length=128)
//	private String departmentName;
	@Column(length=256)
	private String employeeNo;
	@Column(length=256)
	private String employeeName;

	@Column(length=255)
	private String comments;
	
	@Column(length=15)
	private String cUsercode;
	@Column(length=20)
	private String cUsername;//制单人
	private Timestamp cDatetime;
	
	@Column(length=65)
	private String userId;

	@Column(length=128)
	private String enterpriseNo;
	@Column(length=128)
	private String enterpriseName;

	@Version
	private int version = 0;
	
	@Transient//非持久字段
	private RowState rowState;
	public RowState getRowState() {
		return rowState;
	}
	public void setRowState(RowState rowState) {
		this.rowState = rowState;
	}


	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	public Date getRequirementDate() {
		return requirementDate;
	}

	public void setRequirementDate(Date requirementDate) {
		this.requirementDate = requirementDate;
	}
	public BigDecimal getItemWeight() {
		return itemWeight;
	}
	public void setItemWeight(BigDecimal itemWeight) {
		this.itemWeight = itemWeight;
	}
	public String getItemSize() {
		return itemSize;
	}
	public void setItemSize(String itemSize) {
		this.itemSize = itemSize;
	}
	public BigDecimal getOrderWeight() {
		return orderWeight;
	}
	public void setOrderWeight(BigDecimal orderWeight) {
		this.orderWeight = orderWeight;
	}
	public String getOrderSize() {
		return orderSize;
	}
	public void setOrderSize(String orderSize) {
		this.orderSize = orderSize;
	}
	public String getProjectNo() {
		return projectNo;
	}
	public void setProjectNo(String projectNo) {
		this.projectNo = projectNo;
	}
	public String getOrderNo() {
		return orderNo;
	}
	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}
	public int getTaxType() {
		return taxType;
	}
	public void setTaxType(int taxType) {
		this.taxType = taxType;
	}
	public String getTaxTypeLabel() {
		return taxTypeLabel;
	}
	public void setTaxTypeLabel(String taxTypeLabel) {
		this.taxTypeLabel = taxTypeLabel;
	}
	public BigDecimal getTaxRate() {
		return taxRate;
	}
	public void setTaxRate(BigDecimal taxRate) {
		this.taxRate = taxRate;
	}
	public BigDecimal getItemPrice() {
		return itemPrice;
	}
	public void setItemPrice(BigDecimal itemPrice) {
		this.itemPrice = itemPrice;
	}
	public String getStorageType() {
		return storageType;
	}
	public void setStorageType(String storageType) {
		this.storageType = storageType;
	}
	public String getStorageTypeLabel() {
		return storageTypeLabel;
	}
	public void setStorageTypeLabel(String storageTypeLabel) {
		this.storageTypeLabel = storageTypeLabel;
	}
	public String getFloorNo() {
		return floorNo;
	}
	public void setFloorNo(String floorNo) {
		this.floorNo = floorNo;
	}
	public String getShortName() {
		return shortName;
	}
	public void setShortName(String shortName) {
		this.shortName = shortName;
	}
	public String getOriginName() {
		return originName;
	}
	public void setOriginName(String originName) {
		this.originName = originName;
	}
	public Date getOrderDate() {
		return orderDate;
	}
	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getStatus() {
		return status;
	}
	public void setStatus(String status) {
		this.status = status;
	}
	public String getAudit() {
		return audit;
	}
	public void setAudit(String audit) {
		this.audit = audit;
	}
	public String getBillTypeName() {
		return billTypeName;
	}
	public void setBillTypeName(String billTypeName) {
		this.billTypeName = billTypeName;
	}
	public String getFactoryNo() {
		return factoryNo;
	}
	public void setFactoryNo(String factoryNo) {
		this.factoryNo = factoryNo;
	}
	public String getFactoryName() {
		return factoryName;
	}
	public void setFactoryName(String factoryName) {
		this.factoryName = factoryName;
	}
	public BigDecimal getPieceQuantity() {
		return pieceQuantity;
	}
	public void setPieceQuantity(BigDecimal pieceQuantity) {
		this.pieceQuantity = pieceQuantity;
	}
	public String getOrigin() {
		return origin;
	}
	public void setOrigin(String origin) {
		this.origin = origin;
	}
	public String getOriginNo() {
		return originNo;
	}
	public void setOriginNo(String originNo) {
		this.originNo = originNo;
	}
	public Date getConfirmDate() {
		return confirmDate;
	}
	public void setConfirmDate(Date confirmDate) {
		this.confirmDate = confirmDate;
	}
	public String getfID() {
		return fID;
	}

	public void setfID(String fID) {
		this.fID = fID;
	}
	
	public String getBillType() {
		return billType;
	}
	public void setBillType(String billType) {
		this.billType = billType;
	}
		
	public String getStorageNo() {
		return storageNo;
	}
	public void setStorageNo(String storageNo) {
		this.storageNo = storageNo;
	}
	public String getStorageName() {
		return storageName;
	}
	public void setStorageName(String storageName) {
		this.storageName = storageName;
	}
	public String getItemNo() {
		return itemNo;
	}
	public void setItemNo(String itemNo) {
		this.itemNo = itemNo;
	}
	public String getItemDescribe() {
		return itemDescribe;
	}
	public void setItemDescribe(String itemDescribe) {
		this.itemDescribe = itemDescribe;
	}
	public String getUnitCode() {
		return unitCode;
	}
	public void setUnitCode(String unitCode) {
		this.unitCode = unitCode;
	}
	public String getUnitName() {
		return unitName;
	}
	public void setUnitName(String unitName) {
		this.unitName = unitName;
	}
	public BigDecimal getOrderAmount() {
		return orderAmount;
	}
	public void setOrderAmount(BigDecimal orderAmount) {
		this.orderAmount = orderAmount;
	}
	public BigDecimal getOrderAmountOld() {
		return orderAmountOld;
	}
	public void setOrderAmountOld(BigDecimal orderAmountOld) {
		this.orderAmountOld = orderAmountOld;
	}
	public BigDecimal getOrderAmountTax() {
		return orderAmountTax;
	}
	public void setOrderAmountTax(BigDecimal orderAmountTax) {
		this.orderAmountTax = orderAmountTax;
	}
	public BigDecimal getItemAmount() {
		return itemAmount;
	}
	public void setItemAmount(BigDecimal itemAmount) {
		this.itemAmount = itemAmount;
	}

	public String getEnterpriseNo() {
		return enterpriseNo;
	}
	public void setEnterpriseNo(String enterpriseNo) {
		this.enterpriseNo = enterpriseNo;
	}
	public String getEnterpriseName() {
		return enterpriseName;
	}
	public void setEnterpriseName(String enterpriseName) {
		this.enterpriseName = enterpriseName;
	}
	public String getfMasterID() {
		return fMasterID;
	}
	public void setfMasterID(String fMasterID) {
		this.fMasterID = fMasterID;
	}
	public BigDecimal getOrderAmountTotal() {
		return orderAmountTotal;
	}
	public void setOrderAmountTotal(BigDecimal orderAmountTotal) {
		this.orderAmountTotal = orderAmountTotal;
	}

	public String getItemProperty() {
		return itemProperty;
	}

	public void setItemProperty(String itemProperty) {
		this.itemProperty = itemProperty;
	}
	public String getSystemCode() {
		return systemCode;
	}
	public void setSystemCode(String systemCode) {
		this.systemCode = systemCode;
	}
	public String getEmployeeNo() {
		return employeeNo;
	}
	public void setEmployeeNo(String employeeNo) {
		this.employeeNo = employeeNo;
	}
	public String getEmployeeName() {
		return employeeName;
	}
	public void setEmployeeName(String employeeName) {
		this.employeeName = employeeName;
	}
	public String getComments() {
		return comments;
	}
	public void setComments(String comments) {
		this.comments = comments;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getCustomerNo() {
		return customerNo;
	}
	public void setCustomerNo(String customerNo) {
		this.customerNo = customerNo;
	}
	public String getCustomerName() {
		return customerName;
	}
	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}
	public BigDecimal getPickItemIng() {
		return pickItemIng;
	}
	public void setPickItemIng(BigDecimal pickItemIng) {
		this.pickItemIng = pickItemIng;
	}
	public BigDecimal getPickItemAmount() {
		return pickItemAmount;
	}
	public void setPickItemAmount(BigDecimal pickItemAmount) {
		this.pickItemAmount = pickItemAmount;
	}
	public BigDecimal getPickPiece() {
		return pickPiece;
	}
	public void setPickPiece(BigDecimal pickPiece) {
		this.pickPiece = pickPiece;
	}
	public String getStorageTypeD() {
		return storageTypeD;
	}
	public void setStorageTypeD(String storageTypeD) {
		this.storageTypeD = storageTypeD;
	}
	public String getStorageTypeDLabel() {
		return storageTypeDLabel;
	}
	public void setStorageTypeDLabel(String storageTypeDLabel) {
		this.storageTypeDLabel = storageTypeDLabel;
	}
	public String getCustomerID() {
		return customerID;
	}
	public void setCustomerID(String customerID) {
		this.customerID = customerID;
	}
	public String getStorageID() {
		return storageID;
	}
	public void setStorageID(String storageID) {
		this.storageID = storageID;
	}
	public String getItemID() {
		return itemID;
	}
	public void setItemID(String itemID) {
		this.itemID = itemID;
	}
	public BigDecimal getDiscountRate() {
		return discountRate;
	}
	public void setDiscountRate(BigDecimal discountRate) {
		this.discountRate = discountRate;
	}
	public String getFactoryID() {
		return factoryID;
	}
	public void setFactoryID(String factoryID) {
		this.factoryID = factoryID;
	}
	public String getResultStatus() {
		return resultStatus;
	}
	public void setResultStatus(String resultStatus) {
		this.resultStatus = resultStatus;
	}

	public BigDecimal getStoreItemAmount() {
		return storeItemAmount;
	}
	public void setStoreItemAmount(BigDecimal storeItemAmount) {
		this.storeItemAmount = storeItemAmount;
	}
	public String getItemName() {
		return itemName;
	}
	public void setItemName(String itemName) {
		this.itemName = itemName;
	}
	public String getNext() {
		return next;
	}
	public void setNext(String next) {
		this.next = next;
	}
	public String getNextName() {
		return nextName;
	}
	public void setNextName(String nextName) {
		this.nextName = nextName;
	}
	public String getNextNo() {
		return nextNo;
	}
	public void setNextNo(String nextNo) {
		this.nextNo = nextNo;
	}
	public int getQualityType() {
		return qualityType;
	}
	public void setQualityType(int qualityType) {
		this.qualityType = qualityType;
	}
	public String getQualityTypeLabel() {
		return qualityTypeLabel;
	}
	public void setQualityTypeLabel(String qualityTypeLabel) {
		this.qualityTypeLabel = qualityTypeLabel;
	}
	public String getBatchNo() {
		return batchNo;
	}
	public void setBatchNo(String batchNo) {
		this.batchNo = batchNo;
	}
	public int getQualityPeriod() {
		return qualityPeriod;
	}
	public void setQualityPeriod(int qualityPeriod) {
		this.qualityPeriod = qualityPeriod;
	}
	public int getValidDays() {
		return validDays;
	}
	public void setValidDays(int validDays) {
		this.validDays = validDays;
	}
	public int getCheckoutAgainDays() {
		return checkoutAgainDays;
	}
	public void setCheckoutAgainDays(int checkoutAgainDays) {
		this.checkoutAgainDays = checkoutAgainDays;
	}
	public String getStoreNo() {
		return storeNo;
	}
	public void setStoreNo(String storeNo) {
		this.storeNo = storeNo;
	}

	public String getPic() {
		return pic;
	}
	public void setPic(String pic) {
		this.pic = pic;
	}
	public String getProcess() {
		return process;
	}
	public void setProcess(String process) {
		this.process = process;
	}
	public String getProcessLabel() {
		return processLabel;
	}
	public void setProcessLabel(String processLabel) {
		this.processLabel = processLabel;
	}
	public String getBarcode() {
		return barcode;
	}
	public void setBarcode(String barcode) {
		this.barcode = barcode;
	}
	public String getSbomID() {
		return sbomID;
	}
	public void setSbomID(String sbomID) {
		this.sbomID = sbomID;
	}
	public int getLv() {
		return lv;
	}
	public void setLv(int lv) {
		this.lv = lv;
	}
	public int getSttts() {
		return sttts;
	}
	public void setSttts(int sttts) {
		this.sttts = sttts;
	}
	public String getOrderType() {
		return orderType;
	}
	public void setOrderType(String orderType) {
		this.orderType = orderType;
	}
	public String getOrderTypeLabel() {
		return orderTypeLabel;
	}
	public void setOrderTypeLabel(String orderTypeLabel) {
		this.orderTypeLabel = orderTypeLabel;
	}
	public int getCheckin() {
		return checkin;
	}
	public void setCheckin(int checkin) {
		this.checkin = checkin;
	}
	public BigDecimal getBackItemAmount() {
		return backItemAmount;
	}
	public void setBackItemAmount(BigDecimal backItemAmount) {
		this.backItemAmount = backItemAmount;
	}
	public BigDecimal getBackPiece() {
		return backPiece;
	}
	public void setBackPiece(BigDecimal backPiece) {
		this.backPiece = backPiece;
	}
	public BigDecimal getPendingQuantity() {
		return pendingQuantity;
	}
	public void setPendingQuantity(BigDecimal pendingQuantity) {
		this.pendingQuantity = pendingQuantity;
	}
	public BigDecimal getPendingPiece() {
		return pendingPiece;
	}
	public void setPendingPiece(BigDecimal pendingPiece) {
		this.pendingPiece = pendingPiece;
	}
	public String getOriginSerialNo() {
		return originSerialNo;
	}
	public void setOriginSerialNo(String originSerialNo) {
		this.originSerialNo = originSerialNo;
	}
	public String getSerialNo() {
		return serialNo;
	}
	public void setSerialNo(String serialNo) {
		this.serialNo = serialNo;
	}
	public BigDecimal getDiscountAmount() {
		return discountAmount;
	}
	public void setDiscountAmount(BigDecimal discountAmount) {
		this.discountAmount = discountAmount;
	}
	public BigDecimal getPiecePackage() {
		return piecePackage;
	}
	public void setPiecePackage(BigDecimal piecePackage) {
		this.piecePackage = piecePackage;
	}
	public int getFrozenFlag() {
		return frozenFlag;
	}
	public void setFrozenFlag(int frozenFlag) {
		this.frozenFlag = frozenFlag;
	}
	public String getcUsercode() {
		return cUsercode;
	}
	public void setcUsercode(String cUsercode) {
		this.cUsercode = cUsercode;
	}
	public String getcUsername() {
		return cUsername;
	}
	public void setcUsername(String cUsername) {
		this.cUsername = cUsername;
	}
	public Timestamp getcDatetime() {
		return cDatetime;
	}
	public void setcDatetime(Timestamp cDatetime) {
		this.cDatetime = cDatetime;
	}
	public String getSsID() {
		return ssID;
	}
	public void setSsID(String ssID) {
		this.ssID = ssID;
	}
	public int getHandling() {
		return handling;
	}
	public void setHandling(int handling) {
		this.handling = handling;
	}
	public String getHandlingLabel() {
		return handlingLabel;
	}
	public void setHandlingLabel(String handlingLabel) {
		this.handlingLabel = handlingLabel;
	}
	public int getPackFlag() {
		return packFlag;
	}
	public void setPackFlag(int packFlag) {
		this.packFlag = packFlag;
	}
	public String getGuestNumber() {
		return guestNumber;
	}
	public void setGuestNumber(String guestNumber) {
		this.guestNumber = guestNumber;
	}
	public String getAllowed() {
		return allowed;
	}
	public void setAllowed(String allowed) {
		this.allowed = allowed;
	}


}